import { onMounted, reactive } from "vue";
import axios from "axios";

export default function () {
  let dogList = reactive([
    "https://images.dog.ceo/breeds/pembroke/n02113023_4045.jpg",
  ]);

  async function getDog() {
    try {
      let {
        data: { message },
      } = await axios.get("https://dog.ceo/api/breed/pembroke/images/random");
      // console.log(data.message);
      dogList.push(message);
    } catch (error) {
      alert(error);
    }
  }
  onMounted(() => {
    getDog();
  });
  //   向外部提供东西
  return { dogList, getDog };
}
